import {defineStore} from 'pinia'
import { ref } from 'vue'

//自习室模块，目前仅用于自习室页面背景更换，后续进行优化
export const useAgent = defineStore('agent', () => {
    //更换背景状态值，在layout中使用
    const agent = ref({
      name:'',
      content:''
    })

    const setAgentName = (newToken)=>{
      agent.value.name = newToken
    }
    const setAgentContent = (newToken)=>{
      agent.value.content = newToken
    }
    const getAgentName = ()=>{
      return agent.value.name
    }
    const getAgentContent = ()=>{
      return agent.value.content
    }


    const agentList = ref([])
    const addAgent = (newAgent)=>{
      agentList.value.push(newAgent)
    }

    const removeAgent = (newToken)=>{
      agentList.value.splice(agentList.value.indexOf(newToken),1)
    }

    return {
      agent,
      agentList,
      setAgentName,
      setAgentContent,
      getAgentName,
      getAgentContent,
      addAgent,
      removeAgent
    }
  },
)
